package com.danawa.mds.market.model;

import java.math.BigDecimal;

public class Money {
	private final BigDecimal amount;
	
	public Money(BigDecimal amount) {
		this.amount = amount;
	}
	
	public Money(long amount) {
		this(new BigDecimal(amount));
	}
	
	public Money add(Money added) {
		return new Money(this.amount.add(added.amount));
	}

	@Override
	public int hashCode() {
		return amount.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		
		if (!(obj instanceof Money)) {
			return false;
		}
		
		return amount.equals(((Money)obj).amount);
	}

	@Override
	public String toString() {
		return amount.toString();
	}

	public boolean isGreaterThan(Money money) {
		return amount.doubleValue() > money.amount.doubleValue();
	}

	public Money multiply(int quantity) {
		return new Money(amount.multiply(new BigDecimal(quantity)));
	}
}
